package com.yanggu.redisson.config;

import org.redisson.api.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Redisson分布式锁配置类
 */
@Configuration
public class RedissonLockConfig {

    @Bean("test-lock")
    public RLock lock(RedissonClient redissonClient) {
        return redissonClient.getLock("test-lock");
    }

    @Bean("test-semaphore")
    public RSemaphore semaphore(RedissonClient redissonClient) {
        return redissonClient.getSemaphore("test-semaphore");
    }

    @Bean("test-permit-explorable-semaphore")
    public RPermitExpirableSemaphore permitExplorableSemaphore(RedissonClient redissonClient) {
        return redissonClient.getPermitExpirableSemaphore("test-permit-explorable-semaphore");
    }

    @Bean("test-count-down-latch")
    public RCountDownLatch countDownLatch(RedissonClient redissonClient) {
        return redissonClient.getCountDownLatch("test-count-down-latch");
    }

}
